<?php

namespace App\Http\Requests\School;

use Illuminate\Foundation\Http\FormRequest;

/**
 * Class EditSchool
 * @package App\Http\Requests\School
 */
class EditSchool extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'areaId' => 'required|array|size:3',
            'contact_name' => 'required',
            'contact_phone' => ['required', 'regex:/^1[3|4|5|7|8|9][0-9]{9}$/'],
            'detail_address' => 'required'
        ];
    }

    /**
     * @return array
     */
    public function attributes()
    {
        return [
            'areaId' => '学校地址',
            'contact_name' => '联系人',
            'contact_phone' => '联系电话',
            'detail_address' => '学校详细地址'
        ];
    }

    /**
     * @return array
     */
    public function messages()
    {
        return [
            'areaId.required' => '请填写:attribute',
            'areaId.size' => ':attribute缺少参数',
            'areaId.array' => ':attribute数据类型错误',
            'contact_name.required' => '请填写:attribute',
            'contact_phone.required' => '请填写:attribute',
            'contact_phone.regex' => ':attribute格式错误',
            'detail_address.required' => '请填写:attribute'
        ];
    }
}
